//
//  WebService.m
//  veja-baladas
//
//  Created by Bruno Bilescky on 09/08/10.
//  Copyright (c) 2010 __MyCompanyName__. All rights reserved.
//

#import "WebService.h"

@implementation WebService

+(NSString*)makeUrlWith:(NSString*)base and:(NSString*)params {
	NSString* url = [NSString stringWithFormat:base,params];
	return url;
}

+(NSString*)makeStringRequest:(NSString*)request {
	request = [[request stringByReplacingOccurrencesOfString:@" " withString:@"%20"] stringByReplacingOccurrencesOfString:@"\"" withString:@"%22"];
	NSLog(@"%@",request);
	NSURL *url = [NSURL URLWithString:request];
	NSError* error;
	NSString* result = [[[NSString alloc] initWithContentsOfURL:url encoding:NSUTF8StringEncoding error:&error] retain];
	return  result;
}


+(NSDictionary*)dictionaryRequestWith:(NSString*)url {
	NSDictionary* dic = [[[self makeStringRequest:url] JSONValue] retain];
    return dic;
}

+(NSArray*)arrayRequestWith:(NSString*)url {
	NSArray* array = [[[self makeStringRequest:url] JSONValue] retain];
    return array;
}

#pragma mark -
#pragma mark Especific webservices

@end
